package com.heima.wemedia.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.admin.dtos.AdChannelDto;
import com.heima.model.admin.dtos.AdSensitiveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WmChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "自媒体端和管理端频道相关接口", tags = "自媒体端和管理端频道相关接口")
public class WmchannelController {


    @Autowired
    private WmChannelService wmChannelService;


    /**
     *查询频道
     * @return
     */
    @GetMapping("/channels")
    @ApiOperation("自媒体端查询所有频道")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    @PostMapping("/list")
    @ApiOperation("管理端分页查询频道")
    public ResponseResult list(@RequestBody WmChannelDto dto){
        return wmChannelService.list(dto);
    }

    @GetMapping("/del/{id}")
    @ApiOperation("管理端删除频道")
    public ResponseResult del(@PathVariable Integer id){
        return wmChannelService.delChannel(id);
    }

    @PostMapping("/save")
    @ApiOperation("管理端新增频道")
    public ResponseResult save(@RequestBody AdChannelDto dto){
        return wmChannelService.saveChannel(dto);
    }

    @PostMapping("/update")
    @ApiOperation("管理端更新频道")
    public ResponseResult update(@RequestBody AdChannelDto dto){
        return wmChannelService.updateChannel(dto);
    }
}